*****************************************************
***** PROJECT: Measuring Populism in Political Parties: Appraisal of a New Approach
***** AUTHORS: Maurits J. Meijers and Andrej Zaslove
***** PUBLISHED IN: Comparative Political Studies
***** ACCEPTED: March 30, 2020
***** CONTENT: Analyses in main text and appendix
*****************************************************

cd "" 

* Graphing schemes use are 'plotplain' and 'plottig' by Daniel Bischof (www.danbischof.com)

not a command but stops execution of the code if whole do file is ran accidentally

****************************************************************
******** Table 2: Iterated principal EFA ********
****************************************************************
use "dta_1.dta", clear

	factor  manichean indivisble generalwill peoplecentrism antielitism   , ipf mineigen(1) 
	rotate,  orthogonal varimax

*Create predicted populism variable
	predict populism_factor	
	gen populism = ((populism_factor - (-1.616698))/ 3.682342) * 10

****************************************************************
******** Table 3 (Table A2): Spearman Rho Correlations ********
****************************************************************
use "dta_2.dta", clear
	drop if ches_id == .
	merge 1:1 ches_id using "dta_3.dta"
	drop if _merge == 2
	drop _merge
		
	spearman populism antielite_salience
			forvalues cntry = 1/17 {
			list country if country_id == `cntry'
			spearman populism antielite_salience if country_id == `cntry'
			}

			spearman populism antielite_salience if country_id == 20
			
			forvalues cntry = 21/29 {
			list country if country_id == `cntry'
			spearman populism antielite_salience if country_id == `cntry'
			}
	
	bysort country: egen rankpop = rank(populism)
	bysort country: egen rankches = rank(antielite)

****************************************************************
******** Table 4: Iterated principal EFA ********
****************************************************************
use "dta_1.dta", clear

	factor intradem personal manichean indivisble generalwill peoplecentrism antielitism complex emotional lrecon immigration eu nativism laworder lifestyle , ipf mineigen(1)
	rotate, blanks(.5) orthogonal varimax

****************************************************************
******** Table 5: OLS regression ********
****************************************************************
use "dta_2.dta", clear

	reg populism c.lrecon nativism eu lifestyle, cluster(country)
	
****************************************************************
******** Figure 1 and Figure 2 TIF and IFF curves ********
****************************************************************

**** POPPA items ****
use "dta_4.dta", clear
	irt grm manichean indivisble generalwill peoplecentrism antielitism, vce(cluster expert_id)
	irtgraph iif, legend(col(2) position(6)) ysc(r(0 5)) ylabel(0(1)5) ///
		title("Item Information Function: Populism") note("N = 2491" "Clusters = 294", size(small)) saving(iif_poppa, replace)
	irtgraph tif, se legend(position(6)) ysc(r(0 14)) ylabel(0(1)14) /// 
		title("Test Information Function: Populism") note("N = 2491" "Clusters = 294", size(small)) saving(tif_poppa, replace)

**** CHES2017 items ****
use "dta_5.dta", clear
	sort country party
	by country party: gen cntry_expert_id = _n
	bysort country (cntry_expert_id): gen expert_id = (country * 1000) + cntry_expert_id

	irt grm people_vs_elite antielite_salience corrupt_salience, vce(cluster expert_id)
	irtgraph iif, legend(position(6)) ysc(r(0 5)) ylabel(0(1)5) ///
		title("Item Information Function: CHES") note("N = 1988" "Clusters = 230", size(small)) saving(iif_ches2017, replace)
	irtgraph tif, se  legend(position(6)) ylabel(0(2)14) ///
		title("Test Information Function: CHES") note("N = 1988" "Clusters = 230", size(small)) saving(tif_ches2017, replace)

**** Combine graphs ****
graph combine iif_poppa.gph iif_ches2017.gph, ycommon  saving(poppa_ches_IIF, replace)
grc1leg tif_poppa.gph tif_ches2017.gph, ycommon   saving(poppa_ches_TIF, replace)

****************************************************************
******** Figure 3: GPD and PopuList ********
****************************************************************
use "dta_6.dta", clear

	esize twosample populism, by(populist) all
	
	set scheme plotplain
	catplot populist,  over(populism_populist_cat) ///
					note("Point-Biserial r: 0.673" "N=236", size(small))	ytitle("No. of cases") title("PopuList")  saving(PL, replace)

	corr populism gpd 

	graph twoway (scatter populism gpd, mlabel(party) ytitle("Populism") xtitle("GPD Populism Score") ///
		note("Note: Pearson's R: 0.756 (N=15)", size(small)) ) || lfit populism gpd, legend(off) title("Global Populism Database") saving(gpd, replace)
		
	graph combine gpd.gph  PL.gph, col(1)
	
****************************************************************
******** Figure 4: Populism / Left-right ********
****************************************************************
use "dta_2.dta", clear

	twoway scatter populism lroverall, mlabel(party_id) mlabcolor(gs10) legend(off) title("") /// 
		ytitle("Populism") xtitle("Left-Right Position (Overall)") ||  qfit populism lroverall, lcolor(vermillion) 

****************************************************************
******** Figure 5: NL and IT ********
****************************************************************
use "dta_2.dta", clear

	graph twoway  (scatter populism lroverall if country_id == 19 , msymbol(Oh) mlabcolor(black) mlabel(party)) ///
		(scatter  populism lroverall if country_id == 16 , msymbol(S) mlabel(party)  xlabel(0(2)10) xscale(range(0(2)10)) ///
			ytitle("Populism") xtitle("Left-Right Position (Overall)") legend(pos(6))  legend(row(1)) legend(label(1 The Netherlands) label(2 Italy))  saving(nl_ita, replace))

****************************************************************
******** Figure 6: Radical left and radical right ********
****************************************************************
use "dta_2.dta", clear

	set scheme plotplain
	ciplot manichean indivisble generalwill peoplecentrism antielitism if fam==1, saving(rrci, replace) yla(0(2.5)10) title("Radical Right") legend(off) note("") xlabel(, angle(45))
	ciplot manichean indivisble generalwill peoplecentrism antielitism if fam==6, saving(rlci, replace) yla(0(2.5)10) title("Radical Left") legend(off)  note("") xlabel(, angle(45))
	graph combine rrci.gph rlci.gph 
			
****************************************************************
******** Figure 7 and 8: Five country plots ********
****************************************************************
use "dta_2.dta", clear

	gen pos_lr = 3

	replace pos_lr = 6 if (party_id == 1907 | party_id == 1306)
	replace pos_lr = 4 if (party_id == 2607 | party_id == 1904)
	replace pos_lr = 12 if (party_id == 1909 | party_id == 1202 )
	replace pos_lr = 2 if (party_id == 1301 )
	replace pos_lr = 9 if (party_id == 2602 )
	replace pos_lr = 10 if (party_id == 1304 )
		
	graph twoway (scatter populism lrecon if country_id == 13 , msymbol(Dh) mlabsize(vsmall) mlabcolor(black) mlabv(pos_lr) mlabel(party_id)) /// 
				(scatter populism lrecon if country_id == 12 , msymbol(T) mlabsize(vsmall) mlabcolor(black) mlabv(pos_lr) mlabel(party_id)) ///
				(scatter populism lrecon if country_id == 26 , msymbol(Sh) mlabsize(vsmall) mlabcolor(black)mlabv(pos_lr) mlabel(party_id)) ///
				(scatter populism lrecon if country_id == 19 , msymbol(Oh) mlabsize(vsmall) mlabcolor(black) mlabv(pos_lr) mlabel(party_id)) ///
				(scatter  populism lrecon if country_id == 16 , msymbol(S) mlabsize(vsmall) mlabv(pos_lr) mlabel(party_id)  xlabel(0(2)10) xscale(range(0(2)10)) ytitle("Populism") xtitle("Left-Right Position (Economic)") legend(pos(6))  legend(row(1)) legend(label(1 Greece) label(2 Germany) label(3 Spain) label(4 The Netherlands) label(5 Italy)) saving(pop-lrecon-5countries, replace))

	generate pos_eu = 3
	replace pos_eu = 3 if (party_id == 1905 | party_id == 1306 | party_id == 2602 | party_id == 1304 )
	replace pos_eu = 2 if (party_id == 1301 | party_id == 2604 )
	replace pos_eu = 9 if (party_id == 1303 | party_id == 2603 | party_id == 1204 | party_id == 1901 | party_id == 2601  | party_id == 1201)
	replace pos_eu = 10 if (party_id == 1302)
	replace pos_eu = 8 if (party_id == 1310)

	graph twoway (scatter populism eu if country_id == 13 , msymbol(Dh) mlabsize(vsmall) mlabgap(*.6) mlabv(pos_eu) mlabcolor(black) mlabel(party_id)) /// 
			(scatter populism eu if country_id == 12 , msymbol(T) mlabsize(vsmall) mlabgap(*.6) mlabv(pos_eu) mlabcolor(black) mlabel(party_id)) ///
			(scatter populism eu if country_id == 26 , msymbol(Sh) mlabsize(vsmall) mlabgap(*.6) mlabv(pos_eu) mlabcolor(black) mlabel(party_id)) ///
			(scatter populism eu if country_id == 19 , msymbol(Oh) mlabsize(vsmall) mlabgap(*.6) mlabv(pos_eu) mlabcolor(black) mlabel(party_id)) ///
			(scatter  populism eu if country_id == 16 , msymbol(S) mlabsize(vsmall) mlabgap(*.6) mlabv(pos_eu) mlabel(party_id)  xlabel(0(2)10) xscale(range(0(2)10)) ytitle("Populism") xtitle("EU Integration") legend(pos(6))  legend(row(1)) legend(label(1 Greece) label(2 Germany) label(3 Spain) label(4 The Netherlands) label(5  Italy)) saving(pop-eu-5countries, replace))

	generate pos_nat = 3
	replace pos_nat = 9 if (party_id == 2603  | party_id == 1204 | party_id == 2601)
	replace pos_nat = 2 if (party_id == 1301  | party_id == 1903)
	replace pos_nat = 4 if (party_id == 1306  | party_id == 1913 )
	replace pos_nat = 3 if (party_id == 2606)
	replace pos_nat = 12 if (party_id == 1903)

	graph twoway (scatter populism nativism if country_id == 13 , msymbol(Dh) mlabsize(vsmall) mlabgap(*.6) mlabv(pos_nat) mlabcolor(black) mlabel(party_id)) /// 
			(scatter populism nativism if country_id == 12 , msymbol(T) mlabsize(vsmall) mlabgap(*.6) mlabv(pos_nat) mlabcolor(black) mlabel(party_id)) ///
			(scatter populism nativism if country_id == 26 , msymbol(Sh) mlabsize(vsmall) mlabgap(*.6) mlabv(pos_nat) mlabcolor(black) mlabel(party_id)) ///
			(scatter populism nativism if country_id == 19 , msymbol(Oh) mlabsize(vsmall) mlabgap(*.6) mlabv(pos_nat) mlabcolor(black) mlabel(party_id)) ///
			(scatter  populism nativism if country_id == 16 , msymbol(S) mlabsize(vsmall) mlabgap(*.6) mlabv(pos_nat) mlabel(party_id)  xlabel(0(2)10) xscale(range(0(2)10)) ytitle("Populism") xtitle("Nativism") legend(pos(6))  legend(row(1)) legend(label(1 Greece) label(2 Germany) label(3 Spain) label(4 The Netherlands) label(5  Italy)) saving(pop-nativism-5countries, replace))
	
	generate pos_style = 3
	replace pos_style = 9 if (party_id == 1607 | party_id == 1606 | party_id == 1304 )
	replace pos_style = 2 if (party_id == 2603  | party_id == 1903 )
	replace pos_nat = 3 if (party_id == 1310)
	replace pos_style = 10 if (party_id == 2602)
	replace pos_style = 4 if (party_id == 1901)
	replace pos_style = 4 if (party_id == 1301)
	replace pos_style = 6 if (party_id == 1601)

	graph twoway (scatter populism lifestyle if country_id == 13 , msymbol(Dh) mlabsize(vsmall) mlabgap(*.6) mlabv(pos_style) mlabcolor(black) mlabel(party_id)) /// 
			(scatter populism lifestyle if country_id == 12 , msymbol(T) mlabsize(vsmall) mlabgap(*.6) mlabv(pos_style) mlabcolor(black) mlabel(party_id)) ///
			(scatter populism lifestyle if country_id == 26 , msymbol(Sh) mlabsize(vsmall) mlabgap(*.6) mlabv(pos_style) mlabcolor(black) mlabel(party_id)) ///
			(scatter populism lifestyle if country_id == 19 , msymbol(Oh) mlabsize(vsmall) mlabgap(*.6) mlabv(pos_style) mlabcolor(black) mlabel(party_id)) ///
			(scatter  populism lifestyle if country_id == 16 , msymbol(S) mlabsize(vsmall) mlabgap(*.6) mlabv(pos_style) mlabel(party_id)  xlabel(0(2)10) xscale(range(0(2)10)) ytitle("Populism") xtitle("Trad. - Lib. Lifestyle") legend(pos(6))  legend(row(1)) legend(label(1 Greece) label(2 Germany) label(3 Spain) label(4 The Netherlands) label(5  Italy)) saving(pop-lifestyle-5countries, replace))

	grc1leg pop-lrecon-5countries.gph pop-eu-5countries.gph

	grc1leg pop-nativism-5countries.gph pop-lifestyle-5countries.gph	

		
****************************************************************
******** APPENDIX ********
****************************************************************
	
	
****************************************************************
******** Table A1: Iterated principal EFA ********
****************************************************************
use "dta_1.dta", clear

	factor  manichean indivisble generalwill peoplecentrism antielitism, ipf 
	rotate,  orthogonal varimax

****************************************************************
******** Table A2: Spearman Rho Correlations ********
****************************************************************	
	*see Table 3 (above)

****************************************************************
******** Table A3: Case comparisons GPD & PopuList ********
****************************************************************	
use "dta_6.dta", clear
	br if populism_populist_cat == 1
	br if populism_populist_cat == 2
	br if populism_populist_cat == 3	
	
****************************************************************
******** Table A4: Iterated principal EFA ********
****************************************************************
use "dta_1.dta", clear

	factor intradem personal manichean indivisble generalwill peoplecentrism antielitism complex emotional lrecon immigration eu nativism laworder lifestyle , ipf 
	rotate, blanks(.5) orthogonal varimax

****************************************************************
******** Table A5: Iterated principal EFA ********
****************************************************************
use "dta_1.dta", clear

	corr lrecon	nativism immigration laworder lifestyle 

****************************************************************
******** Figure  A1: Nr of experts ********
****************************************************************
use "dta_1.dta", clear

	gen nr_experts_cat = .
	replace nr_experts_cat = 1 if nr_experts < 5
	replace nr_experts_cat = 2 if nr_experts >= 5 & nr_experts <= 8
	replace nr_experts_cat = 3 if nr_experts > 8 & nr_experts <= 12
	replace nr_experts_cat = 4 if nr_experts > 12

	label define nr_experts_cat_lab 1 "< 5 experts" 2 "> 5 ≤ 8 experts" 3 "> 8 ≤ 12 experts" 4 "> 12 ", replace
	label values nr_experts_cat  nr_experts_cat_lab

	catplot  nr_experts_cat, percent  asyvars stack

****************************************************************
******** Figure  A2: Goertzian approach ********
****************************************************************
use "dta_1.dta", clear

		egen popmin = rowmin( manichean indivisble generalwill peoplecentrism antielitism)
		replace popmin = . if manichean == .  |  indivisble == .  |  generalwill == .  |  peoplecentrism == .  |  antielitism == .  
		twoway scatter popmin lroverall, mlabel(party_id) yscale(range(0 10)) ylabel(0(2)10)  mlabcolor(gs10) legend(off) /// 
			title("Goertzian Minimum Approach") ytitle("Goertzian Populism Scale") xtitle("Left-Right Position (Overall)") ||  qfit popmin lroverall, lcolor(vermillion)
	
****************************************************************
******** Figure  A3: Average SDs per party (POPPA & CHES 2014) ********
****************************************************************
use "dta_7.dta", clear

		label variable manichean "Manichean"
		label variable indivisble "Indivisible People"
		label variable generalwill "General Will"
		label variable peoplecentrism "People-Centrism"
		label variable antielitism "Anti-Elitism"
		label variable lroverall "Left-Right (Overall)"
		label variable lrecon "Left-Right (Economic)"
		label variable eu "European Integration"

		graph box  manichean indivisble generalwill peoplecentrism antielitism lroverall lrecon eu, yscale(range(0 7)) ylabel(0(1)7) legend(position(6) cols(2)) title("Our Expert Survey") ytitle("Average standard deviation per party")  saving(SDs_CPS, replace)

use "dta_8.dta", clear

		label variable antielite_salience "Anti-Elite Salience"
		label variable corrupt_salience "Anti-Corruption Salience"
		label variable eu_position "EU Position"
		label variable eu_salience "EU Salience"
		label variable lrgen "Left-Right (Overall)"
		label variable lrecon "Left-Right (Economic)"

		graph box antielite_salience corrupt_salience eu_position eu_salience lrgen lrecon , ///
			legend(position(6) cols(2)) ylabel(0(1)7) title("CHES 2014") ytitle("CHES: Average standard deviation per item") ///
			note("Note: EU Position and EU Salience measured on a 7-point scale", size(vsmall)) ///
			saving(CHES_SDs_CPS, replace)

	graph combine SDs_CPS.gph CHES_SDs_CPS.gph, row(1)
	
****************************************************************
******** Figure  A4: Plot with IRT-predicted variable********
****************************************************************
	use "dta_4.dta", clear
	keep country_id party_id lroverall manichean indivisble generalwill peoplecentrism antielitism manichean_nr indivisbleppl_nr singularppl_nr sovereignppl_nr antielitism_nr
	irt grm manichean indivisble generalwill peoplecentrism antielitism
	predict populism_irt, latent

	collapse (mean)  lroverall manichean indivisble generalwill peoplecentrism antielitism populism_irt   manichean_nr indivisbleppl_nr singularppl_nr sovereignppl_nr antielitism_nr, by(party_id country_id )

	*Make values with less than 4 expers per party/item --> [missing] 
	foreach v of varlist manichean_nr indivisbleppl_nr singularppl_nr sovereignppl_nr antielitism_nr {
	   replace `v' = . if  `v'  <4
	}

	gen popirt_rescaled = ((populism_irt - (-1.189677))/ 3.16163) * 10
	replace popirt_rescaled = . if manichean == .  |  indivisbleppl == .  |  singularppl == .  |  sovereignppl == .  |  antielitism == .  

	twoway scatter popirt_rescaled lroverall, mlabel(party_id) mlabcolor(gs10) legend(off) title("IRT-Predicted Populism Approach") ytitle("IRT-Predicted Populism Scale (Rescaled)") xtitle("Left-Right Position (Overall)") ||  qfit popirt_rescaled lroverall, lcolor(vermillion) 

****************************************************************
******** Figure  A5: 4 item IRT analysis********
****************************************************************
use "dta_4.dta", clear

irt grm  manichean generalwill peoplecentrism antielitism
irtgraph iif, legend(col(2) position(6)) ysc(r(0 5)) ylabel(0(1)5) title("Item Information Function: Populism") saving(iif_poppa_4, replace)
irtgraph tif, se legend(position(6)) ysc(r(0 14)) ylabel(0(1.5)14) title("Test Information Function: Populism") saving(tif_poppa_4, replace)

graph combine iif_poppa_4.gph tif_poppa_4.gph

****************************************************************
******** Figure  A6: correlation matrix (left panel, see R file for right panel)********
****************************************************************
use "dta_9.dta", clear

	graph matrix lroverall lrgen log_rile ratio_rile, half ms(Oh) scale(0.8)

****************************************************************
******** Figure  A7: Scatterplots ********
****************************************************************
use "dta_2.dta", clear

	aaplot pop eu, title(Populism and European Integration) title("") ytitle(Populism) xtitle(European Integration) name(pop_eu, replace)
	aaplot pop lrecon, title(Populism and Left-Right (Economic)) title("") ytitle(Populism) quadratic xtitle(Left-Right (Economic)) name(pop_lrecon, replace)
	aaplot pop nativism, title(Populism and Nativism) ytitle(Populism) title("")  xtitle(Nativism) name(pop_nat, replace) 
	aaplot pop lifestyle, title(Populism and Lifestyle) title("") ytitle(Populism) xtitle(Trad. - Lib. Lifestyle) name(pop_ls, replace)

	graph combine pop_lrecon.gph pop_eu.gph pop_nat.gph pop_ls.gph, saving(combined_pop, replace)

#end
